import { defineStore } from 'pinia'
import { getUserInfor } from '@/api/userinfor'
export const useUserInfor = defineStore('userinfor', {
    state: () => {
        return {
            image_url: '',
            name: '',
            sex: '',
            department: '',
            account: '',
            identity: '',
            email: ''

        }
    },
    actions: {
        async userInfor(id) {
            const res = await getUserInfor(id)
            // console.log(res)
            this.image_url = res.image_url
            this.name = res.name
            this.sex = res.sex
            this.department = res.department
            this.identity = res.identity
            this.account = res.account
            this.email = res.email
        }
    },
    persist: {
        enabled: true,
        key: 'userinfor',
        storage: localStorage,
    }
})